﻿using CSP.Bll;
using CSP.Model.CSP;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace CSP.Web.MyHome.ServiceManage
{
    public partial class WebForm1 : System.Web.UI.Page
    {
        private string treeData = string.Empty;

        public string TreeData
        {
            get { return getTreeString(); }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                
            }
        }
        public string getTreeString()
        {
            StringBuilder sb = new StringBuilder();
            List<ServiceAsset> serviceAsset = GetAssetData();

            foreach (ServiceAsset item in serviceAsset)
            {

            }

            return string.Empty;
        }
        private List<ServiceAsset> GetAssetData()
        {
            //List<AgeGroup> result = new List<AgeGroup>();
            //return result;

            List<CSP.Model.CSP.ServiceAsset> result;
            using (var serviceTypeBll = CSPBllFactory.GetInstance().GetServiceAssetBll())
            {
                result = serviceTypeBll.FindAll().ToList();
            }
            return result;
        }

        public static string DataTable2Json(ServiceAsset dt)
        {
            StringBuilder jsonBuilder = new StringBuilder();
            //jsonBuilder.Append("{\"");
            //jsonBuilder.Append(dt.Name);
            //jsonBuilder.Append("\":[");
            //for (int i = 0; i < dt.Rows.Count; i++)
            //{
            //    jsonBuilder.Append("{");
            //    for (int j = 0; j < dt.Columns.Count; j++)
            //    {
            //        jsonBuilder.Append("\"");
            //        jsonBuilder.Append(dt.Columns[j].ColumnName);
            //        jsonBuilder.Append("\":\"");
            //        jsonBuilder.Append(dt.Rows[i][j].ToString());
            //        jsonBuilder.Append("\",");
            //    }
            //    jsonBuilder.Remove(jsonBuilder.Length - 1, 1);
            //    jsonBuilder.Append("},");
            //}
            //jsonBuilder.Remove(jsonBuilder.Length - 1, 1);
            //jsonBuilder.Append("]");
            //jsonBuilder.Append("}");
            return jsonBuilder.ToString();
        } 

    }
}